/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import bllInterface.*;
import bllfactory.SBLLFactory;
import clientUser.ChatUserImpl;
import java.rmi.RemoteException;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import model.chat.ChatMessageModel;

/**
 *
 * @author salm
 */
public class ClientModel
{
    private ClientModel()
    {
    }
    
    public static ClientModel getInstance() {
        return inst;
    }
    private static ClientModel inst = new ClientModel();
    
    private Account account;
    private iChatUser chatUser;
    private Map<String, ChatMessageModel> chatMsgModels = new HashMap<>();

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
        try {
            this.chatUser = new ChatUserImpl(account, this.getChatMsgModels());
            SBLLFactory.getInstance().getServerChat().login(this.chatUser);
        } catch (RemoteException ex) {
            Logger.getLogger(ClientModel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public iChatUser getChatUser(){
        return chatUser;
    }

    public Map<String, ChatMessageModel> getChatMsgModels() {
        return chatMsgModels;
    }
}
